package com.shujia.scala

object Demo11ScalaApply {
  def main(args: Array[String]): Unit = {
    val stu = new StuA("001", "张三")
    val stuB = new StuB("002", "李四")
    val stuB2 = StuB("003", "王五") // 相当于会去调用StuB的伴生对象中的apply方法
  }
}

class StuA(id: String, name: String) {
  val _id = id
  val _name = name
}

class StuB(id: String, name: String) {
  val _id = id
  val _name = name
}

// class StuB的伴生对象
object StuB {
  def apply(id: String, name: String) = new StuB(id, name)
}

